home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Gfx / show / devedie_0.4.lha / devedie.c < prev    next >
C/C++ Source or Header  |  2004-06-26  |  7KB  |  247 lines

  1. /* Devedie Custom Application Class*/
  2.  
  3.  
  4. #include <exec/types.h>
  5.  
  6. #include <SDI_compiler.h>
  7. #include <SDI_hook.h>
  8.  
  9. #include <libraries/mui.h>
  10.  
  11. #include <clib/alib_protos.h>
  12. #include <proto/asl.h>
  13. #include <proto/dos.h>
  14. #include <proto/exec.h>
  15. #include <proto/graphics.h>
  16. #include <proto/iffparse.h>
  17. #include <proto/intuition.h>
  18. #include <proto/muimaster.h>
  19. #include <proto/utility.h>
  20. #include <ppcinline/dos.h>
  21. #include <proto/icon.h>
  22.  
  23.  
  24. #include <clib/debug_protos.h>
  25. #include "debug.h"
  26. #include "devedie.h"
  27. #include "window.h"
  28. #include "layout_group.h"
  29.  
  30. extern struct Devedie_Layout layout;
  31. extern APTR window;
  32.  
  33. struct EmulLibEntry GATE_Devedie_Dispatcher = {SDI_TRAP_LIB, 0, (APTR)Devedie_Dispatcher};
  34.  
  35. ULONG Devedie_Play(struct IClass *cl,Object *obj,Msg msg)
  36. {
  37.     struct Devedie_Data *data = INST_DATA(cl,obj);
  38.     ULONG i;
  39.     char str[255]={0};
  40.     DB(FPrintf(Output(), "Devedie: play method\n"));
  41.  
  42.     sprintf(str,"run %s -dvd %ld -dvd-device %s -alang %s %s %s",
  43.                             data->mplayer_path,
  44.                             data->dvd_title,
  45.                             data->dvd_device,
  46.                             data->dvd_alang,
  47.                             (data->dvd_framedrop) ? "-framedrop" : "",
  48.                             (data->dvd_fullscreen) ? "-fs" : ""
  49.  
  50.                 );
  51.     DB(FPrintf(Output(), ">%s\n", str));
  52.     SystemTagList(str, TAG_DONE);
  53.     if (data->dvd_continue)
  54.     {
  55.         DoMethod(obj, MUIM_Devedie_FewTitle);
  56.     }
  57. }
  58.  
  59. ULONG Devedie_New(struct IClass *cl,Object *obj,Msg msg)
  60. {
  61.     struct Devedie_Data *data;
  62.     struct TagItem *tags,*tag;
  63.  
  64.     if (!(obj = (Object *)DoSuperMethodA(cl,obj,msg))) return 0;
  65.  
  66.     data = INST_DATA(cl,obj);
  67.     data->dvd_title = 1;
  68.  
  69.     data->disk_object = GetDiskObjectNew("PROGDIR:devedie");
  70.  
  71.     if (data->disk_object)
  72.     {
  73.         set(obj, MUIA_Application_DiskObject, (ULONG)data->disk_object);
  74.         data->mplayer_path   = FindToolType(data->disk_object->do_ToolTypes, "MPLAYER_PATH");
  75.         if (!data->mplayer_path) data->mplayer_path = "sys:apps/mplayer/mplayer";
  76.         data->dvd_device     = FindToolType(data->disk_object->do_ToolTypes, "DVD_DEVICE");
  77.         if (!data->dvd_device) data->dvd_device = "ide.device:1";
  78.         data->dvd_framedrop  = (ULONG)FindToolType(data->disk_object->do_ToolTypes, "FRAMEDROP");
  79.         data->dvd_fullscreen = (ULONG)FindToolType(data->disk_object->do_ToolTypes, "FULLSCREEN");
  80.         data->dvd_alang      = FindToolType(data->disk_object->do_ToolTypes, "ALANG");
  81.         data->dragbar        = (ULONG)FindToolType(data->disk_object->do_ToolTypes, "DRAGBAR");
  82.         set(window, MUIA_Window_Dragbar, data->dragbar);
  83.     if (!data->dvd_alang) data->dvd_alang = "en";
  84.         DB(FPrintf(Output(), "ToolTypes:\n"));
  85.         DB(FPrintf(Output(), " MPLAYER_PATH   %s\n", data->mplayer_path));
  86.         DB(FPrintf(Output(), " DVD_DEVICE     %s\n", data->dvd_device));
  87.         DB(FPrintf(Output(), " AUDIO_LANGUAGE %s\n", data->dvd_alang));
  88.         DB(FPrintf(Output(), " FRAMEDROP      %lx\n", data->dvd_framedrop));
  89.         DB(FPrintf(Output(), " FULLSCREEN     %lx\n", data->dvd_fullscreen));
  90.         DB(FPrintf(Output(), " DRAGBAR        %lx\n", data->dragbar));
  91.   }
  92. /*    for ( tags=((struct opSet *)msg)->ops_AttrList;
  93.                 tag=(struct TagItem *)NextTagItem(&tags);)
  94.     {
  95.         switch (tag->ti_Tag)
  96.         {
  97.             case 1:
  98.                 break;
  99.         }
  100.     }
  101. */
  102.     return (ULONG)obj;
  103. }
  104.  
  105. ULONG Devedie_Dispose(struct IClass *cl,Object *obj,Msg msg)
  106. {
  107.     struct Devedie_Data *data;
  108.     ULONG res;
  109.     data = INST_DATA(cl,obj);
  110.     set(obj, MUIA_Application_DiskObject, 0);
  111.     if (data->disk_object) FreeDiskObject(data->disk_object);
  112.  
  113.     res = (ULONG)DoSuperMethodA(cl,obj,msg);
  114.  
  115.     return TRUE;
  116. }
  117.  
  118. ULONG Devedie_RewTitle(struct IClass *cl,Object *obj,Msg msg)
  119. {
  120.     struct Devedie_Data *data= INST_DATA(cl,obj);
  121.     ULONG i;
  122.  
  123.     if(data->dvd_title>1)
  124.     {
  125.         set(layout.lamp[data->dvd_title-1], MUIA_Selected, FALSE);
  126.         data->dvd_title--;
  127.         set(layout.lamp[data->dvd_title-1], MUIA_Selected, TRUE);
  128.         if (data->dvd_continue)
  129.         {
  130.             for (i=data->dvd_title;i<13;i++)
  131.             {
  132.                 set(layout.lamp[i-1],MUIA_Selected, TRUE);
  133.             }
  134.         }
  135.  
  136.     }
  137.     DB(FPrintf(Output(), "dvd_title is %ld\n", data->dvd_title));
  138.  
  139.     return TRUE;
  140. }
  141.  
  142. ULONG Devedie_FewTitle(struct IClass *cl,Object *obj,Msg msg)
  143. {
  144.     struct Devedie_Data *data = INST_DATA(cl,obj);
  145.     ULONG i;
  146.  
  147.     if(data->dvd_title<12)
  148.     {
  149.         set(layout.lamp[data->dvd_title-1], MUIA_Selected, FALSE);
  150.         data->dvd_title++;
  151.         set(layout.lamp[data->dvd_title-1], MUIA_Selected, TRUE);
  152.     }
  153.     DB(FPrintf(Output(), "dvd_title is %ld\n", data->dvd_title));
  154.  
  155.     return TRUE;
  156. }
  157.  
  158. ULONG Devedie_Set(struct IClass *cl,Object *obj,Msg msg)
  159. {
  160.     struct Devedie_Data *data = INST_DATA(cl,obj);
  161.     struct TagItem *tags,*tag;
  162.  
  163.     for (tags=((struct opSet *)msg)->ops_AttrList;tag=(struct TagItem *)NextTagItem(&tags);)
  164.     {
  165.         switch (tag->ti_Tag)
  166.         {
  167.             case MUIA_Devedie_Continue:
  168.                 {
  169.                     ULONG i;
  170.                     data->dvd_continue = tag->ti_Data;
  171.                     if (data->dvd_continue)
  172.                     {
  173.                         for (i=data->dvd_title;i<13;i++)
  174.                         {
  175.                             set(layout.lamp[i-1],MUIA_Selected, TRUE);
  176.                         }
  177.                     }
  178.                     else
  179.                     {
  180.                         if (data->dvd_title < 11)
  181.                         for (i=data->dvd_title+1;i<13;i++)
  182.                         {
  183.                             set(layout.lamp[i-1],MUIA_Selected, FALSE);
  184.                         }
  185.                     }
  186.                 }
  187.         break;
  188.             case MUIA_Devedie_FullScreen:
  189.                 {
  190.                     data->dvd_fullscreen = tag->ti_Data;
  191.                     DB(FPrintf(Output(), "dvd_fullscreen = %lx\n", data->dvd_fullscreen));
  192.                 }
  193.         break;
  194.             case MUIA_Devedie_FrameDrop:
  195.                 {
  196.                     data->dvd_framedrop  = tag->ti_Data;
  197.                     DB(FPrintf(Output(), "dvd_framedrop = %lx\n", data->dvd_framedrop));
  198.                 }
  199.         break;
  200.         }
  201.     }
  202.  
  203.     return DoSuperMethodA(cl,obj,msg);
  204. }
  205.  
  206. ULONG Devedie_Get(struct IClass *cl,Object *obj,Msg msg)
  207. {
  208.     struct Devedie_Data *data = INST_DATA(cl,obj);
  209.     ULONG *store = ((struct opGet *)msg)->opg_Storage;
  210.  
  211.     switch (((struct opGet *)msg)->opg_AttrID)
  212.     {
  213.     case MUIA_Devedie_FullScreen:
  214.                 {
  215.                     *store = data->dvd_fullscreen;
  216.                 }
  217.         break;
  218.             case MUIA_Devedie_FrameDrop:
  219.                 {
  220.                     *store = data->dvd_framedrop;
  221.                 }
  222.         break;
  223.     }
  224.     return DoSuperMethodA(cl,obj,msg);
  225. }
  226.  
  227.  
  228. ULONG Devedie_Dispatcher(void)
  229. {
  230.   struct IClass *cl=(struct IClass*)REG_A0;
  231.     Msg msg=(Msg)REG_A1;
  232.     Object *obj=(Object*)REG_A2;
  233.     struct Devedie_Data *data = INST_DATA(cl,obj);
  234.  
  235.   switch (msg->MethodID)
  236.     {
  237.         case MUIM_Devedie_Play: return(Devedie_Play(cl,obj,(APTR)msg));
  238.         case OM_NEW           : return(Devedie_New(cl,obj,(APTR)msg));
  239.         case OM_DISPOSE       : return(Devedie_Dispose(cl,obj,(APTR)msg));
  240.         case OM_SET           : return(Devedie_Set(cl,obj,(APTR)msg));
  241.         case OM_GET           : return(Devedie_Get(cl,obj,(APTR)msg));
  242.         case MUIM_Devedie_RewTitle: return(Devedie_RewTitle(cl,obj,(APTR)msg));
  243.         case MUIM_Devedie_FewTitle: return(Devedie_FewTitle(cl,obj,(APTR)msg));
  244.     }
  245.     return DoSuperMethodA(cl,obj,msg);
  246. }
  247.